package com.season.design_pattern.singleton;

/**
 * static语法块，与Mgr01一致
 */
public class Mgr02 {
    private Mgr02(){

    }

    private static Mgr02 INSTANCE;

    static {
        INSTANCE = new Mgr02(); // 必须实例化，不实例化，为null，没有地址，无法使用、赋值
    }

    public static Mgr02 getInstance(){
        return INSTANCE;
    }

    public void sout(){
        System.out.println(this);
    }

    public static void main(String[] args) {
        Mgr02 m1 = Mgr02.getInstance();
        Mgr02 m2 = Mgr02.getInstance();
        System.out.println("m1 == m2 = " + (m1 == m2));
    }

}
